﻿using SEIPropertyDataService.Entity.Converters;
using SEIPropertyDataService.Entity.Enums;
using SqlSugar;
using System;
using System.Text.Json.Serialization;

namespace SEIPropertyDataService.Entity.Models
{
    /// <summary>
    /// 任务记录表
    /// </summary>
    [SplitTable(SplitType.Season)]//按季分表 （自带分表支持 年、季、月、周、日）
    [SugarTable("task_record_{year}{month}{day}")]
    public class TaskRecordModel
    {
        /// <summary>
        /// id
        /// </summary>
        [SugarColumn(IsPrimaryKey = true)]
        public string Id { get; set; }
        /// <summary>
        /// 用户id
        /// </summary>
        public string UserId { get; set; }
        /// <summary>
        /// 运行时提交的数据
        /// </summary>
        [SugarColumn(ColumnDataType = "Text", ColumnDescription = "运行时提交的数据")]
        public string Data { get; set; }
        /// <summary>
        /// 运行结果
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDataType = "Text", ColumnDescription = "运行结果")]
        public string Result { get; set; }
        /// <summary>
        /// 任务状态：0-创建；1-运行中；3-运行结束；4-运行错误
        /// </summary>
        public TaskRecordStatus Status { get; set; }
        /// <summary>
        /// 任务类型
        /// </summary>
        public TaskRecordTypes Type { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        [SplitField]
        [JsonConverter(typeof(CustomDateTimeConverter))]
        [SugarColumn(IsNullable = false, ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true)]
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime UpdateTime { get; set; }
    }
}